Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(type): remove makeObservable and makeAutoObservable function proxy option #3717

Merged
merged 3 commits into from
Jul 14, 2023

Conversation

liucan233
Copy link
Contributor

@liucan233 liucan233 commented Jul 6, 2023

Code change checklist

  • Added/updated unit tests

  • Updated /docs. For new functionality, at least API.md should be updated

  • Verified that there is no significant performance drop (yarn mobx test:performance)

@changeset-bot
Copy link

changeset-bot bot commented Jul 6, 2023

🦋 Changeset detected

Latest commit: 722b126

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@liucan233 liucan233 changed the title fix(type): fix makeObservable and makeAutoObservable function options… fix(type): remove makeObservable and makeAutoObservable function proxy option Jul 6, 2023
@iChenLei iChenLei requested a review from mweststrate July 6, 2023 09:58
@urugator
Copy link
Collaborator

urugator commented Jul 9, 2023

Makes me wonder whether the setting shouldn't be part of annotation/enhancer, so it propagates to nested structures, but probably not worth the additional complexity.

// const foo = observable({}), foo.bar = 1 will be monitored,
// const foo = observable({}, {proxy: false}), foo.bar = 1 will be not monitored
// The summary is that proxy is an invalid option for makeObservable and makeAutoObservable
type NoProxyCreateObservableOptions = Omit<CreateObservableOptions, "proxy">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MakeObservableOptions

@@ -136,6 +136,20 @@ Inference rules:
- All _generator_ functions become `flow`. (Note that generator functions are not detectable in some transpiler configurations, if flow doesn't work as expected, make sure to specify `flow` explicitly.)
- Members marked with `false` in the `overrides` argument will not be annotated. For example, using it for read only fields such as identifiers.

## Options {🚀}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the added section and change the original:

proxy: false forces observable(thing) to use non-proxy implementation. This is a good option if the shape of the object will not change over time, as non-proxied objects are easier to debug and faster. See avoiding proxies.

=>

proxy: false forces observable(thing) to use non-proxy implementation. This is a good option if the shape of the object will not change over time, as non-proxied objects are easier to debug and faster. This option is not available for make(Auto)Observable, see avoiding proxies.

Copy link
Member

@mweststrate mweststrate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liucan233 thanks for the PR! Mind following up on the review feedback posted earlier? Beyond that looking good to me so happy to merge.

@liucan233
Copy link
Contributor Author

Thank you for all pointing out my errors, and All errors have been corrected. Perhaps it will take you some time to check again.

@iChenLei
Copy link
Member

@liucan233 Hi, You don't need to force push your code (otherwise, we would need to trigger CI manually every time). If your PR is accepted, we will merge it using Squash and merge

@urugator urugator merged commit 55f78dd into mobxjs:main Jul 14, 2023
@urugator
Copy link
Collaborator

Thank you!

This was referenced Jul 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants